using System;
using System.Collections.Generic;
using System.Text;

namespace My.IdlConverter.Core
{
    using Filters;

    public class Interface
    {
        private bool _isAbstract = false;
        private string _name = "";
        private IList<Method> _methods = new List<Method>();

        public virtual Method this[string methodName]
        {
            get
            {
                foreach (Method nextMethod in _methods)
                {
                    if (nextMethod.Name.Equals(methodName))
                        return nextMethod;
                }
                return null;
            }
        }

        public virtual Method this[int index]
        {
            get
            {
                return _methods[index];
            }
        }

        public Interface(string name)
        {
            _isAbstract = true;
            _name = name;
        }

        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }

        public virtual IList<Method> Methods
        {
            get
            {
                return _methods;
            }
        }

        public override string ToString()
        {
            return Name;
        }

        public virtual bool IsClass()
        {
            return false;
        }

        public virtual int Depth
        {
            get
            {
                return 0;
            }
        }

        public bool Abstract
        {
            get
            {
                return _isAbstract;
            }
            set
            {
                _isAbstract = value;
            }
        }

        public bool IsFinal()
        {
            return (!Abstract);
        }

        public virtual string ClueWord
        {
            get
            {
                return InterfaceModifier.GetTitle(Name);
            }
        }

        public override bool Equals(object obj)
        {
            Interface other = obj as Interface;
            if (other == null && this == null)
                return true;
            if (other == this)
                return true;
            if (other == null || this==null)
                return false;

            return this.Name.Equals(other.Name);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
